package com.katarina.ad.panels.menu;

import org.springframework.stereotype.Component;

import com.vaadin.ui.Tree;

@Component("leftMenu")
public class LeftMenu extends Tree {
  private static final long serialVersionUID = -5769052971510862392L;

  public LeftMenu() {
    //    setSizeFull();
    setHeight("95%");
    setWidth("95%");

    for (Menu m : Menu.values()) {
      if (m.getParentMenu() == null) {
        addItem(m.getTitle());
        expandItem(m.getTitle());
      } else {
        if (!areChildrenAllowed(m.getParentMenu().getTitle())) {
          setChildrenAllowed(m.getParentMenu().getTitle(), true);
        }
        addItem(m.getTitle());
        setParent(m.getTitle(), m.getParentMenu().getTitle());
        setChildrenAllowed(m.getTitle(), false);
      }
    }
  }
}